﻿using System.Diagnostics;

namespace Runtime.Services.Battle {

    /// <summary>
    /// 战斗单元格ID
    /// </summary>
    [DebuggerStepThrough]
    [DebuggerNonUserCode]
    public readonly struct DFR_BattleCellID {

        public static readonly DFR_BattleCellID Invalid = new() { Index = DFR_BattleCellIndex.Invalid, Axis = DFR_BattleCellAxis.Invalid };

        /// <summary>
        /// 索引
        /// </summary>
        public DFR_BattleCellIndex Index { get; init; }

        /// <summary>
        /// 坐标
        /// </summary>
        public DFR_BattleCellAxis Axis { get; init; }

        public override bool Equals(object obj) {
            if (obj is DFR_BattleCellID other) {
                return other.Index == Index;
            }
            return false;
        }

        public override string ToString() {
            if (Index == DFR_BattleCellIndex.Invalid) {
                return $"[{nameof(DFR_BattleCellID)}({nameof(Invalid)})]";
            } else {
                return $"[{nameof(DFR_BattleCellID)}({nameof(Axis.X)}={Axis.X},{nameof(Axis.Y)}={Axis.Y},{nameof(Index)}={Index.Value})]";
            }
        }
        public override int GetHashCode() => Index.GetHashCode();

        public static bool operator ==(DFR_BattleCellID left, DFR_BattleCellID right) => left.Equals(right);
        public static bool operator !=(DFR_BattleCellID left, DFR_BattleCellID right) => !left.Equals(right);
    }
}
